from rest_framework.views import  APIView
from rest_framework import serializers
from meiduo_admin.serializers.login_serializer import *
from rest_framework.response import Response

class LoginView(APIView):
    def post(self, request):
        serializer = LoginSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        return Response({
            'username':serializer.validated_data['user'].username,
            'user_id': serializer.validated_data['user'].id,
            'token': serializer.validated_data['token'].token,
        })